<?php
session_save_path('sessions');
session_start();

// Include the different user types so we can filter out unauthorized users
include("include/dbUserTypes.php");

// Include our user class
include_once("include/user.php");

// Create a variable to store our user if we're validated
$user = null;

// Check if we're in a valid session. If not, go back to main login page.
if( !isset($_SESSION['user']) || $_SESSION['user'] == null ) {
    header("location:main_login.php");
}
else {
    // Unserialize our user to turn it back into a useful object
    $user = unserialize($_SESSION['user']);
}

// If we're not a business (or admin) go back to the user redirection page
if( $user->getUserType() != $USERTYPE_BUSINESS && $user->getUserType() != $USERTYPE_ADMIN)
    header("location:login_success.php");

// Include the header (CSS files, etc)
include("include/header.php"); ?>

<body>
  <div id="wrapper">
    <div id="header"> </div>
    <div id="left">
      <div id="logo">
        <h1>Home Sale</h1>
        <p>Only By Owner</p>
      </div>
      <div id="nav">
        <ul>
          <li><a href="login_success.php">Business Index</a></li>
          <li class="important"><a href="addadvertisement.php">Add Advertisement</a></li>
          <li><a href="">View Reports</a></li>
          <li><a href="searchhouse.php">Search House</a></li>
          <li><a href="logout.php">Logout</a></li>
        </ul>
      </div>
      <div id="news">
        <?php include("adgeneratorleft1.php");?>
        <div class="hr-dots"> </div>
        <?php include("adgeneratorleft2.php");?>
        <p class="more"><a href="login_success.php">more</a></p>
      </div>
      <div id="support">
      </div>
    </div>
    <div id="right">
      <h2>Add Advertisement</h2>
      <div id="welcome">
        <script type="text/javascript">
          function changeText(){
          var userInput = document.getElementById('userInput').value;
          var cost = userInput*0.5;
          document.getElementById('pricing').innerHTML = cost;
          }
        </script>
          
          <form action="adsvalidation.php" method="post">
            <b>Title:</b><input type="text" name="title" />
            <br></br>
            <b>Content:</b>
            <br></br>
            <textarea name="content" cols="40" row="5">Enter content</textarea>
            <br></br>
            <b>Preferred Industry:</b>
            <br></br>
            <tr><td><input type="radio" name="preferredIndustry" value="Agriculture" checked/> Agriculture</td><td><input type="radio" name="preferredIndustry" value="Banking" /> Banking</td></tr>
            <br></br>
	          <tr><td><input type="radio" name="preferredIndustry" value="Entertainment" /> Entertainment</td><td><input type="radio" name="preferredIndustry" value="Consulting" /> Consulting</td></tr>
            <br></br>
	          <tr><td><input type="radio" name="preferredIndustry" value="Health Care" /> Health Care</td><td><input type="radio" name="preferredIndustry" value="Other" /> Other</td></tr>
            <br></br>
            <b>Location:</b>
            <br></br>
			      <tr><td><input type="radio" name="location" value="1" checked /> Left 1</td><td><input type="radio" name="location" value="2" />Left 2</td></tr>
            <tr><td><input type="radio" name="location" value="3"  /> Bottom Left</td><td><input type="radio" name="location" value="4" />Bottom Right</td></tr>
            <br></br>
              <b>Select number of displays:</b>
                <select id='userInput' name="viewAmount" onchange="changeText()">
                  <option value="5000">Min</option>
                  <option value="5000">5 000</option>
                  <option value="6000">6 000</option>
                  <option value="7000">7 000</option>
                  <option value="8000">8 000</option>
                  <option value="9000">9 000</option>
                  <option value="10000">10 000</option>
                </select>
            <br></br>
            <p><b>Price: </b><b id="pricing"></b></p>
            <br></br>
			      <input type="submit" value="Preview" />
            <input type="reset" />
        </form>
      </div>
      <h3></h3>
      <div id="profile">
        <div id="corp">
          <?php include("adgeneratorbottomleft.php");?>
        </div>
        <div id="indu">
          <?php include("adgeneratorbottomright.php");?>
        </div>
      </div>
    </div>
    <div class="clear"> </div>
    <div id="spacer"> </div>
    <div id="footer">
      <div id="copyright">
        &copy; Template taken from http://www.freewebsitetemplates.com/
      </div>
	  <div id="footerline"></div>
    </div>
	
  </div>
</body>
</html>
